package com.gitee.chenyaohua.utils;

public class StringUtils {

    private final static String splitChar="_";

    public static String defaultIfEmpty(String str,String defaultStr){
        return StringUtils.isBlank(str)?defaultStr:str;
    }

    public static boolean isBlank(String str) {
        return str==null || str.trim().equals("");
    }

    public static String strCamelCase(String str){
        if(!StringUtils.isBlank(str)){
            String[] spt = str.split(splitChar);

            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < spt.length; i++) {
                String s = spt[i];
                String c = String.valueOf(s.charAt(0));
                if(i==0){
                    sb.append(s.replaceFirst(c, c.toLowerCase()));
                }else{
                    sb.append(s.replaceFirst(c, c.toUpperCase()));
                }

            }

            return  sb.toString();
        }

        return str;
    }
}
